import { UserInfoRep } from "@/api/user";
import { getMoneyApi } from "@/api/userWallt";
import { WithDrawType } from "@/api/withdraw";
import { server } from "@/utils/server";
import WithdrawWidget from "./WithdrawWidget";
// 获取提现配置列表
// POST /v1/api/user/user_withdraw_config
// 接口ID：222886924
// 接口地址：https://app.apifox.com/link/project/4790544/apis/api-222886924

const getWithdrawApi = async () => {
    return server
        .request<WithDrawType[]>({
            url: "/v1/api/user/user_withdraw_config",
            method: "post",
        })
        .then((res) => {
            if (res.code === 200) {
                return res.data;
            }
            return [];
        });
};
const getUserInfo = async () => {
    return server
        .request<UserInfoRep>({
            url: "/v1/api/user/user_info",
            method: "POST",
            next: { revalidate: 0 },
        })
        .then((res) => {
            if (res.code === 200) return res.data;
            return {};
        });
};
const Page = async () => {
    const data = await getWithdrawApi();
    const wallet = await getMoneyApi();
    const userInfo = await getUserInfo();
    return <WithdrawWidget channels={data} wallet={wallet} playlist={userInfo.play_list} />;
};

export default Page;
